﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAO
{
    public class DataProvider
    {
        public static SqlConnection ConnectionData()
        {
            string cnStr = @"Data Source=THANHBUI\SQLEXPRESS;Initial Catalog=QUANLYRAPCHIEUPHIM_DOAN_PTUDCSDL1;Integrated Security=True";
          // string cnStr = @"Data Source=MINHTHUY-PC\SQLEXPRESS;Database=QUANLYRAPCHIEUPHIM_DOAN_PTUDCSDL1;Trusted_Connection=True";
            //string cnStr = @"Data Source=HP-PC\TOLINH;Initial Catalog=QUANLYRAPCHIEUPHIM_DOAN_PTUDCSDL1;Integrated Security=True";
            SqlConnection cn = new SqlConnection(cnStr);
            cn.Open();
            return cn;
        }
        public static int executeNonQuery(string sql)
        {
            int kq = -1;

            SqlConnection cn = ConnectionData();
            try
            {
                SqlCommand cmd = new SqlCommand(sql, cn);
                kq = cmd.ExecuteNonQuery();
                cn.Close();
            }
            catch (SqlException)
            {
                cn.Close();
                kq = -1;
            }
            return kq;
        }
    }
}
